

function previe(fang)
{
    if (fang < 10){
        bdhtml=window.document.body.innerHTML;//获取当前页的html代码
        sprnstr="<!--startprint"+fang+"-->";//设置打印开始区域
        eprnstr="<!--endprint"+fang+"-->";//设置打印结束区域
        prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18); //从开始代码向后取html
        prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//从结束代码向前取html
        window.document.body.innerHTML=prnhtml;
        window.print();
        window.document.body.innerHTML=bdhtml;
    } else {
        window.print();
    }
}



//批量上传
function template() {
    var str1="";
    $.ajax({
        url:"getList",
        type:"POST",
        dataType:'json',
        success:function (data) {
            console.log(data.list1);
            str1="<td>"+data.list1.ID+"</td>"+
                "<td>"+data.list1.cystimName+"</td>"+
                "<td>"+data.list1.bank+"</td>"+
                "<td>"+data.list1.rate+"</td>"+
                "<td>"+data.list1.limit+"</td>"+
                "<td>"+data.list1.deadline+"</td>"+
                "<td>"+data.list1.interestType+"</td>"+
                "<td>"+data.list1.report+"</td>";

            $("#j2").html(str1);
        }
    })
}

//清空实现
function resetQuery() {
    $("#userAccount").val("");
    $("#sUserBank").val("");
}



//查询
$("#queryBtn").click(function(){
    var filters = {
        'customer':$("#userAccount").val(),
        'bankq':$("#sUserBank").val()
    };
    grid.jqGrid("setGridParam", { postData: filters ,page: 1});
    grid.trigger('reloadGrid');
});
//根据条件查询
$(function() {

    //加载该页面前，先判断该模块的权限
    //获取当前登录的用户的权限
    var permission = document.cookie.split(";")[1].split("=")[1];
    var b = String(permission).split('');
    for (var i = 0; i < b.length; i++) {
        console.log(b[i]);
    }
    var moudle41 = b[12];
    //如果模块权限为1，即只能查询此模块下的数据，不能进行修改（禁用和重置密码不能使用）
    //系统管理
    flag = true;
    if (moudle41 == 1) {
        $("#addNewBtn").css('display', 'none');
        $("#addNewBtn1").css('display', 'none');
        $("#addNewBtn2").css('display', 'none');
        flag = false;
    }

    var str="";
    $.ajax({
        url:"getBank",
        type:"POST",
        dataType:'json',
        success:function (data) {
            console.log(data.Bank[0].BANKNAME);
            str="<option ></option>"+
                "<option value='"+data.Bank[0].BANKNAME+"'>"+data.Bank[0].BANKNAME+"</option>"+
                "<option value='"+data.Bank[1].BANKNAME+"'>"+data.Bank[1].BANKNAME+"</option>"+
                "<option value='"+data.Bank[2].BANKNAME+"'>"+data.Bank[2].BANKNAME+"</option>"+
                "<option value='"+data.Bank[3].BANKNAME+"'>"+data.Bank[3].BANKNAME+"</option>"+
                "<option value='"+data.Bank[4].BANKNAME+"'>"+data.Bank[4].BANKNAME+"</option>";
            $("#sUserBank").html(str);
        }
    });

    var pageNo = 1;
    var pageSize = 7;
    var grid_selector = "#grid-table";
    var pager_selector = "#grid-pager";
    //初始化数据表格
    grid = $(grid_selector).jqGrid({
        datatype: "json",
        url: 'getFind',
        mtype: 'POST',
        page: pageNo,
        postData: {
            'customer':$("#userAccount").val(),
            'bankq':$("#sUserBank").val()
        },
        height: 380,
        width: 300,
        colNames: ['客户编号', '客户名称', '所属银行', '信用评级', "授信额度（元）", '授信期限（月）', "还款方式", "授信报告"],
        colModel: [
            {name: 'id', index: 'id', align: 'center', sortable: false},
            {name: 'CUSTOMERNAME', index: 'CUSTOMERNAME', align: 'center', sortable: false},
            {name: 'BANKNAME', index: 'BANKNAME', align: 'center', sortable: false},
            {name: 'CREDITGRADE', index: 'CREDITGRADE', align: 'center', sortable: false},
            {name: 'CREDITLIMIT', index: 'CREDITLIMIT', align: 'center', sortable: false},
            {name: 'CREDITBERIOD', index: 'CREDITBERIOD', align: 'center', sortable: false},
            {name: 'Repayment', index: 'Repayment', align: 'center', sortable: false},
            {name: 'Report', index: 'Report', align: 'center', sortable: false}
        ],
        //定义是否显示总记录数
        viewrecords: true,
        //在grid上显示记录条数，这个参数是要被传递到后台
        rowNum: pageSize,
        //添加左侧行号
        rownumbers: false,
        //一个选择下拉框
        rowList: [7, 14, 21],
        //定义翻页用的导航
        pager: pager_selector,
        //设置表格 zebra-striped 值
        altRows: true,
        //定义是否可以多选
        multiselect: false,
        loadComplete: function (data) {
            var table = this;
            setTimeout(function () {
                updatePagerIcons(table);
            }, 0);
            /*  var h = $(window).height() - ($('#grid-pager')[0].offsetHeight + 15) - ($('.result-table .box')[0].offsetTop + $('.ui-jqgrid-bdiv')[0].offsetTop + 3);
              $('.ui-jqgrid-bdiv').height(h);*/
        },
        autowidth: true,
        jsonReader: jsonReader,   // json中代表实际模型数据的入口
        rownumWidth: 55,
        prmNames: prmNames,
        recordtext: "显示 {0} - {1} 条 , 共 {20} 条",
        emptyrecords: "没有记录",
        /*loadtext: "正在加载...",*/
        pgtext: "第 {0} 页  ,共 {1} 页"
    });
    //初始化分页条
    showNavGrid(grid_selector, pager_selector);

});